import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const routes: any = []
routes.push( {
  path: '/',
  name: 'home',
  component: HomeView
})
routes.push( {
  path: '/about',
  name: 'about',
  // route level code-splitting
  // this generates a separate chunk (About.[hash].js) for this route
  // which is lazy-loaded when the route is visited.
  component: () => import('../views/AboutView.vue')
})
const supportEncoding = ['base64', 'base32', 'base58','hex']
for (let item of supportEncoding) {
  let objEncode = {
    path: '/encoding/encode' + item,
    name: 'encode' + item,
    component: () => import('../components/encoding/BaseEncodeView.vue')
  }
  let objDecode = {
    path: '/encoding/decode' + item,
    name: 'decode' + item,
    component: () => import('../components/encoding/BaseEncodeView.vue')
  }
  routes.push(objEncode)
  routes.push(objDecode)
}
routes.push({
  path: '/encoding/qrcode',
  name: 'qrcode',
  component: () => import('../components/encoding/QRCodeView.vue')
})
routes.push({
  path: '/program/sqlpretty',
  name: 'sqlpretty',
  component: () => import('../components/programing/SqlPretty.vue')
})
routes.push({
  path: '/program/cryptosha',
  name: 'crypto-sha',
  component: () => import('../components/programing/CryptoSha.vue')
})
routes.push({
  path: '/program/cryptohmac',
  name: 'crypto-hmac',
  component: () => import('../components/programing/CryptoHmac.vue')
})
routes.push({
  path: '/program/cryptoaes',
  name: 'crypto-aes',
  component: () => import('../components/programing/CiphersAes.vue')
})
routes.push({
  path: '/program/crypto3des',
  name: 'crypto-3des',
  component: () => import('../components/programing/Ciphers3Des.vue')
})
routes.push({
  path: '/program/pemparser',
  name: 'crypto-pemparser',
  component: () => import('../components/programing/PemParser.vue')
})
routes.push({
  path: '/program/pgpkeygen',
  name: 'crypto-pgpkeygen',
  component: () => import('../components/programing/PGPKeyGen.vue')
})
routes.push({
  path: '/program/pwdgen',
  name: 'crypto-pwdgen',
  component: () => import('../components/programing/PwdGen.vue')
})

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: routes
})

export default router
